<?php
/**
 * Created by littleU.
 * User: littleU
 * Date: 2021-01-29
 * Time: 13:44
 */

namespace app\api\model;


class Product extends BaseModel
{
    public function sku()
    {
        return $this->hasMany('productSku', 'item_code', 'code')->where('sku_status',1);
    }

    public function mainImg()
    {
        return $this->hasMany('productImage', 'product_id','id')->where('status',1);
    }

    public function commentList()
    {
        return $this->hasMany('productComment','product_id','id');
    }

    public function category()
    {
        return $this->hasOne('productCategory', 'id', 'category_id')->bind(['category_name'=>'name']);
    }

    public function property()
    {
        return $this->hasMany('productProperty','item_code','code');
    }

    public function detailContent()
    {
        return $this->hasOne('productDetail', 'product_id', 'id')->bind('detail');
    }
}